﻿/******************************************************************************
 * 【本类功能概述】                                 					      *
 *  版权所有（C）2017-20XX，梦匠科技                                          *
 *  保留所有权利。                                                            *
 ******************************************************************************
 *  作者 : <PC-shijiankai>
 *****************************************************************************/
using UnityEngine;
using System.Collections.Generic;
namespace CSV
{
/// <summary>
/// 角色表 阵营|类型|种类
/// </summary>
public class Role
{
	private volatile static CSVReader _instance = null;
    private static readonly object lockHelper = new object();
	/// <summary>
	/// 角色表 阵营|类型|种类
	/// </summary>
	public const string _id="id";
	/// <summary>
	/// 名字
	/// </summary>
	public const string _name="name";
	/// <summary>
	/// 血量
	/// </summary>
	public const string _HP="HP";
	/// <summary>
	/// 行为
	/// </summary>
	public const string _Behavior="Behavior";
	/// <summary>
	/// 模型
	/// </summary>
	public const string _path="path";
	/// <summary>
	/// 碰撞宽度
	/// </summary>
	public const string _radius="radius";

	public class line
    {
		/// <summary>
		/// 角色表 阵营|类型|种类
		/// </summary>
		public int id;
		/// <summary>
		/// 名字
		/// </summary>
		public string name;
		/// <summary>
		/// 血量
		/// </summary>
		public float HP;
		/// <summary>
		/// 行为
		/// </summary>
		public CsvArrayInt Behavior;
		/// <summary>
		/// 模型
		/// </summary>
		public string path;
		/// <summary>
		/// 碰撞宽度
		/// </summary>
		public float radius;

    }
    private static Dictionary<string, line> m_datadic = new Dictionary<string, line>();
    public static line getline(string id)
    {
        if (m_datadic.ContainsKey(id))
        {
            return m_datadic[id];
        }
        else
        {
            line _line = new line();
			_line.id = Instance().getintById(id, _id);
			_line.name = Instance().getstringById(id, _name);
			_line.HP = Instance().getfloatById(id, _HP);
			_line.Behavior = Instance().getCsvArrayIntById(id, _Behavior);
			_line.path = Instance().getstringById(id, _path);
			_line.radius = Instance().getfloatById(id, _radius);

            m_datadic.Add(id, _line);
            return _line;
        }
    }
	
	public static CSVReader Instance()
	{
        if(_instance == null)
        {
            lock(lockHelper)
            {
                if(_instance == null)
                     _instance = ConfigManager.GetCsvData("Role");
            }
        }
        return _instance;
    }
}
}